﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;

namespace WebApplication1
{

    public abstract class Shape1
    {
         public abstract int Area();
        public virtual int Area3()
        {
            throw new NotImplementedException();
        }
    }
    public interface IAnimal
    {
        //string Age { get; set; }

        string Survive();
    }
    public interface ICat: IAnimal
    {
        string Fly();      
        new string Survive();
    }
    public interface IDog:IAnimal
    {
        string Barg();
    }

   

    public interface IRedDog:IDog
    {
        string RedBarg();
    }

    public class RedDog :Dog, IRedDog
    {
        public RedDog()
        {
            
        }
        public RedDog(string name)
        {
            
        }

        private int _myage;

        public string Name { get; set; }
        public string Email { get => _email; set => _email = value; }
        private string _email;

        public override string VBarg()
        {
            return "";
        }

        public string Barg()
        {
            throw new NotImplementedException();
        }

        public string RedBarg()
        {
            throw new NotImplementedException();
        }

        public string Survive()
        {
            throw new NotImplementedException();
        }
    }

    public class Animal : IAnimal
    {
        private string Animalprivate()
        {
            return "";
        }

        public string Animalpublic()
        {
            return "";
        }

        public string Age { get ; set ; }

        public string Survive()
        {
            
            Console.WriteLine("I Can Survive");
            return "";
        }

        public static string Survive2()
        {
            Console.WriteLine("I Can Survive2");
            return "";
        }
    }

    public class Cat : Animal,ICat, IAnimal
    {
        public Cat()
        {
            
        }
        public string Fly()
        {
            base.Survive();
            Console.WriteLine("I Can Survive");
            return "";
        }

       public string Survive()
        {
            Console.WriteLine("I Can Survive");
            return "";
        }        
    }

    public class Dog : Animal,IDog, IAnimal
    {
        private string Dogprivate()
        {
            return "";
        }

        public string Dogpublic()
        {
            return "";
        }

        public virtual string VBarg()
        {
            return "";
        }

        public string Barg()
        {
            Console.WriteLine("I Can Survive");
            return "";
        }

        public string Survive()
        {
            Console.WriteLine("I Can Survive");
            return "";
        }
    }



    public interface IDrawingObject
    {
        // Raise this event before drawing 
        // the object. 
        event EventHandler OnDraw;
        string Test1();
    }
    public interface IShape
    {
        // Raise this event after drawing 
        // the shape. 
        event EventHandler OnDraw;
        string Test1();
    }

    public class Shape : IDrawingObject, IShape
    {
        public event EventHandler OnDraw;

        public string Test()
        {
            Console.WriteLine("I Can Survive");
            return "";
        }

        public string Test1()
        {
            Console.WriteLine("I Can Survive");
            return "";
        }
    }

    public class Program
    {
        
        
        private int _age = 10;

        public int Age
        {
            get { return _age; }
            set
            {
                if (value < 1 || value > 120)
                    throw new System.ArgumentException("年龄只能在1-120范围内。");
                _age = value;
            }
        }

        public static bool Dlag => string.Equals("123", "", StringComparison.Ordinal) ? true : false;

        public static string GetHello() =>
            "Send" + DateTime.Now;

        public static string Hello { get; set; }
            = "Send" + DateTime.Now;

        public static string Hello2
        {
            get { return "Send" + DateTime.Now; }
            set { ; }
        }

        public static string Hello6 => "Send" + DateTime.Now;
        
            


        public static void Main(string[] args)
        {
            //Dog d66 =new RedDog();
            //d66.VBarg();
            //Type ggggggg=d66.GetType();
            //var ddggggg=System.Activator.CreateInstance(ggggggg.BaseType);
            

            Type type = Type.GetType("WebApplication1.Shape");
            IAnimal d =(IAnimal)Activator.CreateInstance(Type.GetType("WebApplication1.Cat"));
            //Activator.CreateInstance(Type.GetType("你的类名"));
            Type ggg=d.GetType();
            d.Survive();


            IDrawingObject shape = new Shape();
            shape.Test1();
            Type t=shape.GetType();
            int hh=shape.GetHashCode();

            IShape shape2 = new Shape();

            shape.Test1();
            Type t2 = shape2.GetType();
            int h3h = shape2.GetHashCode();

            IAnimal cat = new Cat();
            cat.Survive();
            Type t3 = cat.GetType();

            ICat cat2 = new Cat();
            cat.Survive();
            Type t23 = cat2.GetType();

            string dg=GetHello();
            string dg1= GetHello();                                                                                                                                                                                                                                                                                                  

            string dg3 = Hello;
            string dg4 = Hello;

            string dg5 = Hello2;
            string dg6 = Hello2;
            CreateWebHostBuilder(args).Build().Run();
        }

        public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
            WebHost.CreateDefaultBuilder(args)
                .UseStartup<Startup>();
    }
}
